﻿<%@ Page Title="" Language="C#" MasterPageFile="~/Site.master" AutoEventWireup="true"
    CodeFile="Stock.aspx.cs" Inherits="Stock_Stock" %>

<asp:Content ID="Content1" ContentPlaceHolderID="HeadContent" runat="Server">
    <title>Stock</title>
</asp:Content>
<asp:Content ID="Content2" ContentPlaceHolderID="MainContent" runat="Server">
    <asp:Panel ID="pnlStock" runat="server" Visible="true">
        <h2>Stock</h2><br />
        <div id="divSucursal" runat="server">
            <asp:Label ID="lblSucursal" runat="server" Text="Sucursal"></asp:Label>
            <asp:DropDownList ID="ddlBranch" runat="server" DataTextField="BranchName" DataValueField="BranchId"
                OnSelectedIndexChanged="ddlBranch_SelectedIndexChanged" AutoPostBack="true">
            </asp:DropDownList>
            &nbsp;&nbsp;<asp:ImageButton ID="imgAdd" runat="server" ImageUrl="~/Images/icon_add.png" OnClick="imgAdd_Click" />
        </div>
        <div id="divProducts">
            <asp:GridView ID="GridView1" runat="server" AutoGenerateColumns="False" CellPadding="4"
                ForeColor="#333333" GridLines="None" Width="100%">
                <AlternatingRowStyle BackColor="White" />
                <Columns>
                    <asp:BoundField DataField="ProductDesctiption" HeaderText="Producto">
                        <ItemStyle HorizontalAlign="Center" />
                    </asp:BoundField>
                    <asp:BoundField DataField="ProductPrice" HeaderText="Precio" DataFormatString="{0:f}">
                        <ItemStyle HorizontalAlign="Center" />
                    </asp:BoundField>
                    <asp:BoundField DataField="Quantity" HeaderText="Cantidad">
                        <ItemStyle HorizontalAlign="Center" />
                    </asp:BoundField>
                </Columns>
                <EditRowStyle BackColor="#2461BF" />
                <FooterStyle BackColor="#507CD1" Font-Bold="True" ForeColor="White" />
                <HeaderStyle BackColor="#507CD1" Font-Bold="True" ForeColor="White" />
                <PagerStyle BackColor="#2461BF" ForeColor="White" HorizontalAlign="Center" />
                <RowStyle BackColor="#EFF3FB" />
                <SelectedRowStyle BackColor="#D1DDF1" Font-Bold="True" ForeColor="#333333" />
                <SortedAscendingCellStyle BackColor="#F5F7FB" />
                <SortedAscendingHeaderStyle BackColor="#6D95E1" />
                <SortedDescendingCellStyle BackColor="#E9EBEF" />
                <SortedDescendingHeaderStyle BackColor="#4870BE" />
            </asp:GridView>
        </div>
    </asp:Panel>
    <asp:Panel ID="pnlProviders" runat="server" Visible="false">
        <asp:DetailsView ID="DetailsView1" runat="server" Height="50px" Width="125px" AutoGenerateRows="False"
            CellPadding="4" DefaultMode="Insert" ForeColor="#333333" GridLines="None" DataKeyNames="ProductId,BranchId,ProviderId,Date"
            DataSourceID="EntityDataSource1" 
            OnItemInserted="DetailsView1_ItemInserted" 
            OnItemInserting="DetailsView1_ItemInserting">
            <AlternatingRowStyle BackColor="White" />
            <CommandRowStyle BackColor="#D1DDF1" Font-Bold="True" />
            <EditRowStyle BackColor="#2461BF" />
            <FieldHeaderStyle BackColor="#DEE8F5" Font-Bold="True" />
            <Fields>
                <asp:BoundField ConvertEmptyStringToNull="False" DataField="ProductId" HeaderText="ProductId"
                    ReadOnly="True" SortExpression="ProductId" Visible="False" />
                <asp:BoundField ConvertEmptyStringToNull="False" DataField="BranchId" HeaderText="BranchId"
                    ReadOnly="True" SortExpression="BranchId" Visible="False" />
                <asp:BoundField ConvertEmptyStringToNull="False" DataField="ProviderId" HeaderText="ProviderId"
                    ReadOnly="True" SortExpression="ProviderId" Visible="False" />
                <asp:BoundField ConvertEmptyStringToNull="False" DataField="Quantity" HeaderText="Quantity"
                    SortExpression="Quantity" Visible="False" />
                <asp:BoundField ConvertEmptyStringToNull="False" DataField="Date" HeaderText="Date"
                    SortExpression="Date" Visible="False" ReadOnly="True" />
                        <asp:TemplateField HeaderText="Producto">
                    <InsertItemTemplate>
                        <asp:DropDownList ID="ddlProducts" runat="server" DataTextField="ProductDesctiption"
                            DataValueField="ProductId">
                        </asp:DropDownList>
                    </InsertItemTemplate>
                </asp:TemplateField>
                <asp:TemplateField HeaderText="Provedor">
                    <InsertItemTemplate>
                        <asp:DropDownList ID="ddlProviders" runat="server" DataTextField="ProviderName" DataValueField="ProviderId">
                        </asp:DropDownList>
                    </InsertItemTemplate>
                </asp:TemplateField>
                <asp:TemplateField HeaderText="Cantidad">
                    <InsertItemTemplate>
                        <asp:TextBox ID="txtQuantity" runat="server"></asp:TextBox>
                    </InsertItemTemplate>
                </asp:TemplateField>
                <asp:CommandField ShowInsertButton="True" />
            </Fields>
            <FooterStyle BackColor="#507CD1" Font-Bold="True" ForeColor="White" />
            <HeaderStyle BackColor="#507CD1" Font-Bold="True" ForeColor="White" />
            <PagerStyle BackColor="#2461BF" ForeColor="White" HorizontalAlign="Center" />
            <RowStyle BackColor="#EFF3FB" />
        </asp:DetailsView>
        <asp:EntityDataSource ID="EntityDataSource1" runat="server" ConnectionString="name=ObligatorioDotNetEntities"
            DefaultContainerName="ObligatorioDotNetEntities" EnableFlattening="False" EnableInsert="True"
            EntitySetName="ProviderProductBranches">
        </asp:EntityDataSource>
    </asp:Panel>
    <asp:hyperlink ID="Hyperlink1" runat="server" NavigateUrl = "~/Stock/Historico.aspx">Historico</asp:hyperlink>
</asp:Content>
